<!DOCTYPE html>
<html >
<head>
<meta charset="utf-8">
<title>购买</title>
<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="stylesheet" href="css/mui.css">
<link rel="stylesheet" href="css/app.css">
<link rel="stylesheet" href="css/weui.css">
<script type="text/javascript" src="js/utile.js"></script>
 <script type="text/javascript" src="js/jquery-2.0.0.min.js"></script>
 <script type="text/javascript">
        var orderCombo;
        var rootArea;
        var endDate;
        var type;
        
        var comboId;
$(document).ready(function(){
	
		var url = getURL() + "/mobile/buyfamily";
		  var pram = {};
		  $.ajax({
			  type: 'POST',
			  url: url,
			  data: pram,
			  success: function(data){
				  comboList = data.comboList;
				  $(".first").empty();
					var option = $("<option>").val("-1").text("请选择体检套餐"); 
				  $(".first").append(option); 
				  for (var i = 0;i<data.comboList.length;i++){
					  var item = data.comboList[i];
					  for (var j = 0;j<item.contentList.length;j++){
						  var content = item.contentList[j];
						  if(content.itemType == "1"){
// 							  if(data.isSelf == "y" && content.sex != data.sex){
// 								  continue;
// 							  }
							  var option = $("<option>").val(content.itemId).text(content.itemName); 
							  option.attr("price",content.price);
							  option.attr("comboId",item.comboId);
							  $(".first").append(option); 
						  }
					  }
				  }
			  },
			  dataType: "json"
			});
});
function firstChange(obj){
	var option=$(obj).find("option:checked");
	   var price=option.attr("price");
	   comboId=option.attr("comboId");
	   $(".price").val(price);
}

function back(){
	window.location.href = "beforeFamily.html";
}

function commit(){
	if(!$('.first').val() || $('.first').val() == -1) {
		alert("请选择升级前套餐");
		return false;
	}
	var url = getURL() + "/mobile/toBuyfamily";
	  var pram = {};
	  pram.itemId = $('.first').val();
	  pram.comboId = comboId;
	  
	  var str = "?";
	  for ( var p in pram ){ 
		  if ( typeof ( pram [ p ]) == " function " ){ 
		  } else { // p 为属性名称，obj[p]为对应属性的值 
		  	str +=  p + "=" + pram [ p ] + "&"
		  }
	  }
	  url = url+str;
	  $.ajax({
		  type: 'POST',
		  url: url,
		  data: pram,
		  success: function(data){
			  if(data.success){
				  if(data.url == "1") {
					  window.location.href = getURL() + "/mobile/topay?orderUpId=" + data.orderUpId;
				  } else {
					  window.location.href = "order.html?type=2";
				  }
			  }
		  },
		  dataType: "json"
		});
	
}

</script>

</head>

<body >
<header id="header" class="mui-bar mui-bar-nav"> <a onclick="history.go(-1)" class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left" style="color:#fff;"></a>
  <h1 class="mui-title">家属购买</h1>
</header>
<div class="container loginTop" style="width:80%;">
  <div>
  
  <div>
	    <h5>购买套餐</h5>
	    <div class="weui_cell weui_cell_select weui_select_after">
	      <div class="weui_cell_bd weui_cell_primary">
	        <select class="weui_select first" name="select" onchange="firstChange(this);">
	          <option value="1">是</option>
	          <option value="2">否</option>
	        </select>
	      </div>
	    </div>
  </div>
    <div>
      <h5 style="width:100%; line-height:30px; padding-top:10px;"><span style="float:left;">金额：</h5>
      <span style="float:right; width:80%;">
      <input name="" type="text" value=""  class="btInp price" readonly="true" style="height:30px; " onmouseover="this.style.borderColor='#30a5ff'" onmouseout="this.style.borderColor='#c9c9c9'">
      </span>
      <div style="clear:both;"></div>
      <p>
        <input type="radio" name="radio" id="pay" value="pay" checked="true">
        <label for="pay">支付宝金额</label>
      </p>
    </div>
  </div>
  <div class="pt30 textCent"><a onclick="commit()" class="weui_btn weui_btn_mini weui_btn_plain_blue " style="width: 30%;padding: 5px;">下一步</a> <a onclick="back()" class="weui_btn weui_btn_mini weui_btn_plain_blue" style="width: 30%;padding: 5px; margin-left:20px;">取消</a> </div>
</div>
</div>
</body>
</html>